<?php

abstract class Base_fetch {

	public static function http_post($url, $params) {
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $params); //设置POST提交的字符串 
		curl_setopt($ch, CURLOPT_TIMEOUT, 30);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Android;async-http/1.4.1)');
		// curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //信任任何证书
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 检查证书中是否设置域名,0不验证
		$r = curl_exec($ch);
		curl_close($ch);
		
		return $r;
	}

	public static function generate_token($key, $value, $date) { 
		$salt  = "slightech";
		$token = md5($salt.$key.$value.$date); 
		return $token;
	}

	public static function http_get($url) {
		return file_get_contents($url);
	}

	public static function send_mail($title, $content) {
		mail('jackyang@slightech.com', $title, $content);
	}

}